package com.example.practical_training_projects.controller;
import com.example.practical_training_projects.entity.test;
import com.example.practical_training_projects.entity.user;
import com.example.practical_training_projects.service.testService;
import com.example.practical_training_projects.service.testselectService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.practical_training_projects.entity.testselect;

import java.util.List;
@RestController
@CrossOrigin //允许跨域执行
@RequestMapping("testselect")
public class testselectController {
    @Autowired
    private testselectService service;
    @GetMapping("list")
    public List<testselect> getAllclass(){
        return service.getAllclass();
    }
    //分页
    @GetMapping("/page")
    public PageInfo<testselect> gettestselectpage(Integer pageNum, Integer pageSize){
        PageInfo<testselect> pageInfo = service.findtestselectpage(pageNum,pageSize);
        return pageInfo;
    }

    @GetMapping("/get/{ts_class}")
    public testselect findTestclass(@PathVariable("ts_class") String ts_class){
        return service.findTestclass(ts_class);
    }

    @PostMapping("add")
    public Integer insertClass(@RequestBody testselect ts_class) {
        return service.insertClass(ts_class);

    }
    @GetMapping("/query/{class}")
    public List<testselect> gettestselectClass(@PathVariable("class")String ts_class){
        return service.gettestselectClass(ts_class);
    }

    @PostMapping("update")
    public Integer updateClass(@RequestBody testselect testselect1){
        return service.updateClass(testselect1);
    }
}
